/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package LogicadeNegocio;
import CapadeDatos.DaoVerCarreras;
import modelo.beancarrera;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import modelo.beancarrera1;
/**
 *
 * @author hans
 */
    public class VerCarreras {
    JTable tabla;
    JComboBox jcombo;
    ArrayList lista;
    beancarrera[] detalles;
    JTextField textbox;
    DefaultTableModel dtm;
    public VerCarreras(JTable tablaext){
         tabla = tablaext;
    }

    public VerCarreras(JComboBox combo) {
          jcombo = combo;
    }
    public void vercarreras(){
      ArrayList lista = DaoVerCarreras.carrera();
      Iterator iterador = lista.iterator();
      while (iterador.hasNext()) {
      beancarrera elemento = (beancarrera) iterador.next();
      Object[] newRow={elemento.getCodigo(),elemento.getNombrecarrera()};
           dtm =(DefaultTableModel) tabla.getModel();
           dtm.addRow(newRow);
      }
      tabla.setModel(dtm);
    }

    public void cargarcarrera() throws Exception{
     // Llamamos al metodo datos modulo que nos devuelve el ArrayList
      lista = (ArrayList) DaoVerCarreras.carrera();
      detalles = new beancarrera[lista.size()];
      Iterator itr = lista.iterator();
      int j=0;
      jcombo.removeAllItems();
      while (itr.hasNext()) {
          detalles[j] =  (beancarrera) itr.next();
          jcombo.addItem(detalles[j].getNombrecarrera());
          j++;
      }

    }
    public  beancarrera[] semestre(){
      return detalles;
    }
}
